using System;
using System.Collections.Generic;
using System.Text;
using JobShopModel.Model.Job;
using JobShopModel.Model.FactoryLvl;

//TODO Doculentation
namespace JobShopModel.Model.Station
{
    /// <summary>
    /// 
    /// </summary>
    class StationIO : IStations
    {


        private Time operationTime;
        private Time iddleTime;
        private Time blockedTime;

        private StationsStates states;
        private StationsList name;


        public Jobs CreateJob()
        {
            Random rand = new Random();
            double tmprand;
            tmprand = rand.NextDouble();
            if(tmprand <= .3)
                return Jobs.CreateJob(JobsTypes.JOB1);
            else if(tmprand <=.8)
                return Jobs.CreateJob(JobsTypes.JOB2);
            else
                return Jobs.CreateJob(JobsTypes.JOB3);
        }


        public void TerminateJob(Jobs job)
        {
            Operation op = job.getNexOperation();
            if (op.Station == StationsList.IOSTATION)
            {
                op.Status = OperationStatus.DONE;
                op.OperationTime = new Time(0.0);
            }
            else
            {
                throw new Exception("Can not terminate job, there is other operations ....");
            }
        }


        public Time OperationTime
        {
            get
            {
                return operationTime;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public Time IddleTime
        {
            get
            {
                return iddleTime;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public Time BlockedTime
        {
            get
            {
                return blockedTime;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public StationsStates State
        {
            get
            {
                return states;
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public Time PerformOperation(Operation op)
        {
            return op.MeanServiceTime;
        }

        public StationsList Name
        {
            get { return name; }
        }

    }
}
